{include file="public/_head"}
    <!-- /Navbar -->
    <!-- Main Container -->
    <div class="main-container container-fluid">
        <!-- Page Container -->
        <div class="page-container">
{include file="public/_left"}
            <!-- Page Sidebar -->
            
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>&nbsp;文章管理
                        </li>
                        <li>文章列表</li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->
                <!-- Page Body -->
                <div class="page-body">
					<a href="{:url('admin/article/add')}" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i>&nbsp;添加文章</a>
					<div class="row">
						<div class="col-xs-12">
							<div class="widget">
								<div class="widget-header">
									<span class="widget-caption">添加文章</span>
									<div class="widget-buttons">
										{$articles->render()|raw|replace}
									</div>
								</div>
								<div class="widget-body">
									<table class="table table-hover table-bordered">
										<thead>
											<tr>
												
												<th>文章标题</th>									
												<th>文章标签</th>									
												<th>文章导航</th>
												<th>文章描述</th>
												<th>创建时间</th>
												<th>操作</th>
											</tr>
										</thead>
										{volist name="articles" id="vo"}
										<tr>
											<td>{$vo.title}</td>
											<td>{$vo.tags}</td>
											<td>{$vo.cate.catename}</td>
											<td>{$vo.desc}</td>
											<td>{$vo.create_time}</td>
											<td>
											{if $vo.is_top==1}
												<a href="#" class="btn btn-sm btn-darkorange article-top" istopid="{$vo.is_top}" dataid="{$vo.id}">取消推荐</a>
												{else /}
												<a href="#" istopid="{$vo.is_top}" dataid="{$vo.id}" class="btn btn-sm btn-azure article-top">推荐</a>
												{/if}
												<a href="{:url('admin/article/edit',['id'=>$vo.id])}" class="btn btn-sm btn-warning">编辑</a>
												<a href="#" dataid="{$vo.id}" class="btn btn-sm btn-danger articledel">删除</a>
											</td>
										</tr>
										{/volist}
									</table>
								</div>
							</div>
						</div>
					</div>
                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->

        </div>
        <!-- /Page Container -->
        <!-- Main Container -->

    </div>

   {include file="public/_js"}
   <script type="text/javascript">
   $(function(){
   	$('.article-top').click(function(){
   		var id=$(this).attr('dataid');
   		var is_top=$(this).attr('istopid');
   		if (is_top==1) {
   			var msg="确定取消推荐么？";
   		}else{
   			var msg="确定推荐么？";
   		}
   		layer.confirm(msg,{
   			title:'推荐操作',
   			icon:3
   		},function(index){
   			layer.close(index);
   			$.ajax({
   				url:"{:url('admin/article/top')}",
   				type:'post',
   				data:{id:id,is_top:is_top},
   				dataType:'json',
   				success:function(data){
   					if(data.code==1){
   						layer.msg(data.msg,{
   							icon:6,
   							time:2000
   						},function(){
   							location.href=data.url;
   						});
   					}else{
   						layer.open({
   							title:'操作失败',
   							content:data.msg,
   							icon:5,
   							anim:6
   						});
   					}
   				}
   			});
   		});


   		return false;
   	});
    
    $('.articledel').click(function(){
    	var id=$(this).attr('dataid');
    	layer.confirm('确定删除么？',{
    		title:'文章删除',
    		icon:3,
    	},function(index){
    		layer.close(index);
    		$.ajax({
    		url:"{:url('admin/article/del')}",
    		type:'post',
    		data:{id:id},
    		dateType:'json',
    		success:function(data){
    			if(data.code==1){
    				layer.msg(data.msg,{
    					icon:6,
    					time:2000,
    				},function(){
    					location.href=data.url
    				});
    			}else{
    				layer.open({
    					title:'删除文章',
    					content:data.msg,
    					icon:5,
    					anim:6
    				});
    			}
    		}


    	});
    	});



    	return false;
    });	

   });

   </script>
</body>
<!--  /Body -->
</html>
